﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpAlgorithm
{
    class LCS
    {
        public LCS()
        {
            //입력
            int aLength = GetConsole.GetInt();
            int[] a = new int[aLength];
            int bLength = GetConsole.GetInt();
            int[] b = new int[bLength];
            for (int i = 0; i < aLength; i++)
            {
                a[i] = GetConsole.GetInt();
            }
            for (int i = 0; i < bLength; i++)
            {
                b[i] = GetConsole.GetInt();
            }
            int[,] ab = new int[aLength, bLength];
            if(a[0] == b[0])
            { ab[0,0] = 1; }
            for (int j = 1; j < bLength; j++)
            {
                if (ab[0, j - 1] == 1 || ab[0, j - 1] == -1)
                { ab[0, j] = -1; }
                else if (a[0] == b[j])
                { ab[0, j] = 1; }
            }
            for (int i = 1; i < aLength; i++)
            {
                if (a[i] == b[0])
                {
                    ab[i, 0] = 1;
                }
            }
            for (int i = 1; i < aLength; i++)
            {
                for (int j = 1; j < bLength; j++)
                {
                    if (a[i] == b[j])
                    {
                        if (ab[i - 1, j] < 0)
                        {
                            ab[i, j] = -(ab[i - 1, j] - 1);
                        }
                        else if (ab[i - 1, j] == 0)
                        {
                            ab[i, j] = 1;
                        }
                    }
                    else
                    {
                        if (Math.Abs(ab[i - 1, j]) > Math.Abs(ab[i, j - 1]))
                        {

                        }
                    }
                }
            }
        }
    }
}
